﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ClientDW.Entities
{
    public class GCOverallCompanySummaryExtended : GCOverallCompanySummary, IEqualityComparer<GCOverallCompanySummaryExtended>
    {
        public List<GCPrincipleTemplate> NonCompliantPrinciples { get; set; }
        public DateTime? NonCompliantSince { get; set; }
        public List<GCPrincipleTemplate> WatchListPrinciples { get; set; }
        public DateTime? WatchListSince { get; set; }

        

        public bool Equals(GCOverallCompanySummaryExtended x, GCOverallCompanySummaryExtended y)
        {
            if (x == null && y == null)
                return true;

            if (x == null || y == null)
                return false;

            return
                new GCOverallCompanySummary().Equals(x, y)
                && ((x.NonCompliantPrinciples == null && y.NonCompliantPrinciples == null)
                    || (x.NonCompliantPrinciples != null && y.NonCompliantPrinciples != null && x.NonCompliantPrinciples.SequenceEqual(y.NonCompliantPrinciples, new GCPrincipleTemplate())))
                && ((x.NonCompliantSince == null && y.NonCompliantSince == null) || (x.NonCompliantSince.Value.Date == y.NonCompliantSince.Value.Date))
                && ((x.WatchListPrinciples == null && y.WatchListPrinciples == null)
                    || (x.WatchListPrinciples != null && y.WatchListPrinciples != null && x.WatchListPrinciples.SequenceEqual(y.WatchListPrinciples, new GCPrincipleTemplate())))
                && ((x.WatchListSince == null && y.WatchListSince == null) || (x.WatchListSince.Value.Date == y.WatchListSince.Value.Date));
        }

        public int GetHashCode(GCOverallCompanySummaryExtended obj)
        {
            return this.Id.GetHashCode();
        }
    }
}
